package com.ruoyi.wx.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.wx.entity.PtClassExpAll;
import com.ruoyi.wx.mapper.PtClassExpAllMapper;
import com.ruoyi.wx.service.IPtClassExpAllService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.checkerframework.checker.units.qual.C;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 班级本学期要做的全部实验 服务实现类
 * </p>
 *
 * @author moxiu
 * @since 2022-03-04
 */
@Service
public class PtClassExpAllServiceImpl extends ServiceImpl<PtClassExpAllMapper, PtClassExpAll> implements IPtClassExpAllService {

    @Override
    public long[] getOneByClassId(Long classId) {
        PtClassExpAll ptClassExpAll = baseMapper.selectOne(Wrappers.lambdaQuery(PtClassExpAll.class)
            .eq(PtClassExpAll::getClassId, classId)
            .select(PtClassExpAll::getExpList)
        );

        if (ptClassExpAll == null) {
            return null;
        }
        String expList = ptClassExpAll.getExpList();
        List<Integer> parse = (List<Integer>) JSONObject.parse(expList);
        long[] res = new long[parse.size()];
        for (int i = 0; i < parse.size(); i++) {
            res[i] = parse.get(i);
        }
        return res;
    }
}
